home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / ArchiveUtils / nx_arc / arctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  1.4 KB  |  60 lines

  1. /*
  2.  * $Log:        arctst.c,v $
  3.  * Revision 1.3  87/08/13  17:06:06  hyc
  4.  * Run thru indent, fixed some signed vs. unsigned problems
  5.  * with bp <-> buf, and inbuf and localbuf...
  6.  *  Revision 1.2  87/07/21  09:24:37  hyc *** empty
  7.  * log message ***
  8.  * 
  9.  */
  10.  
  11. /*
  12.  * ARC - Archive utility - ARCTST
  13.  * 
  14.  * Version 2.12, created on 02/03/86 at 23:00:40
  15.  * 
  16.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  17.  * 
  18.  * By:  Thom Henderson
  19.  * 
  20.  * Description: This file contains the routines used to test archive integrity.
  21.  * 
  22.  * Language: Computer Innovations Optimizing C86
  23.  */
  24. #include <stdio.h>
  25. #include "arc.h"
  26.  
  27. INT
  28. tstarc()
  29. {                /* test integrity of an archive */
  30.     struct heads    hdr;    /* file header */
  31.     LONG            arcsize, ftell();    /* archive size */
  32.  
  33.     openarc(0);        /* open archive for reading */
  34.     fseek(arc, 0L, 2);    /* move to end of archive */
  35.     arcsize = ftell(arc);    /* see how big it is */
  36.     fseek(arc, 0L, 0);    /* return to top of archive */
  37.  
  38.     while (readhdr(&hdr, arc)) {
  39.         if (ftell(arc) + hdr.size > arcsize) {
  40.             printf("Archive truncated in file %s\n", hdr.name);
  41.             nerrs++;
  42.             break;
  43.         } else {
  44.             printf("Testing file: %-12s  ", hdr.name);
  45.             fflush(stdout);
  46.             if (unpack(arc, NULL, &hdr))
  47.                 nerrs++;
  48.             else
  49.                 printf("okay\n");
  50.         }
  51.     }
  52.  
  53.     if (nerrs < 1)
  54.         printf("No errors detected\n");
  55.     else if (nerrs == 1)
  56.         printf("One error detected\n");
  57.     else
  58.         printf("%d errors detected\n", nerrs);
  59. }
  60.